<? //Controller functionality
	include_once('inc.php');
	
	//if(isset($_REQUEST['File'])){
	if(isset($_FILES['File']))
	{
		//print_r($_FILES['File']);
		$rs = array('UserId' => 0, 'TypeId' => 3, 'Value' => $_FILES['File']['name']); //TypeId 3 is an unused id in DataBase, Value will come from a web URL for this example
			//File in Value is linked to File input name on form
		$fileparts = pathinfo($_FILES['File']['name']);
		$id = ContactMethod::Save($rs);
		$filename = "upload/$id." . $fileparts['extension'];
		move_uploaded_file($_FILES['File']['tmp_name'], $filename);
		chmod($filename, 644);
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>File Upload Example</title>
    </head>
    
    <body>
    	<form method="post" enctype="multipart/form-data"> <!-- always post back to own script, enctype -->
        	<label>FILE:</label>
            <input name="File" type="file" /> <!-- name File allows Controller up top to take item and load to DataBase, type file adds a browse button to get files off desktop -->
            <input type="submit" value="Submit"/>
        </form>
        <img src="<?=$filename?>" />
    </body>
</html>